package com.wzh.dao;

import com.wzh.pojo.Po.*;
import com.wzh.pojo.Req.DataReq;
import com.wzh.pojo.Resp.DataResp;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
@Mapper
public interface UserDao {

//	@Update("update user set username=#{username},tel=#{tel},email=#{email} where useridid=#{useridid}")
//	int updatbyid(User user);

	@Delete("delete from user where userid=#{userid}")
	int deonebyid(User user);



	@Select("select * from user ")
	List<User> getAll();

	@Select("select * from user where userid=#{userid}")
	List<User> getbyid(Long id);


	@Select("select * from user where userid=#{userid} and password=#{password}")
	User login(User user);


	@Select("delete * from card where card=#{card}")
	int selectcard(String card);
	@Update("update user set money=money+#{money} where userid=#{userid}")
	int addmoney(User user);
	@Insert("insert into user (userid,password,createtime) value (#{userid},#{password},NOW())")
	int register(User user);

	@Select("select * from user where userid=#{userid}")
	User findUserid(User user);

	@Select("select * from list")
	List<NameList> readList();
//   @Select("select a.userid,a.password,a.identity,a.money,b.rname  identityName from user a,roleType b where a.identity=b.rid                                  \n" +
//		   "limit #{pageIndex},#{pageCount}")
	List<User> findall(DataReq req);



	int delmoney(User user2);
	//申请提现
	@Insert("insert into cash (cash_id,iphone,time,money,info) value (#{cashId},#{iphone},NOW(),#{money},#{info})")
	int sendCashRecord(Cash cash);

	//查看用户是否存在提交待审核记录
	@Select("select cash_id as cashId,iphone,time,money,info from cash where iphone=#{iphone} and  status=0")
	Cash findCashRecord(Cash cash);
    //审核提现是否通过

	Integer checkCashRecord(Cash cash);
//	@Select("select * from cash where iphone=#{userid} limit #{pageIndex},#{pageCount}")
	List<Cash> getCashRecord(DataReq req);



	//上传用户收益记录 风控
	@Insert("insert into tb_money_record (userid,time,money,imei,model) value (#{userid},NOW(),#{money},#{imei},#{model})")
	int Sendrecoed(User user);

	@Select("select userid iphone,imei,model,money,time from tb_money_record where userid=#{userid} ORDER BY id DESC limit #{pageIndex},#{pageCount}")
	List<Cash> getMoneyRecord(DataReq req);


	@Update("update user set imei=#{imei},model=#{model} where userid=#{userid}")
	int boundDev(User user);


	@Update("update user set imei=NULL,model=NULL where userid=#{userid}")
	int DelDev(User user);


	int UPdateVipTime(User user);

    @Delete("delete from user where userid=#{userid} ")
	int delUser(DataReq req);
}
